package com.ruoyi.legal.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.page.Pages;
import com.ruoyi.common.core.page.Query;
import com.ruoyi.common.query.QueryTool;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.legal.mapper.WorkDetailMapper;
import com.ruoyi.legal.domain.WorkDetail;
import com.ruoyi.legal.service.IWorkDetailService;

/**
 * 工作详情Service业务层处理
 * 
 * @author xwj
 * @date 2025-04-29
 */
@Service
public class WorkDetailServiceImpl extends ServiceImpl<WorkDetailMapper, WorkDetail> implements IWorkDetailService {
    @Autowired
    private WorkDetailMapper workDetailMapper;

    /**
     * 查询工作详情
     * 
     * @param id 工作详情主键
     * @return 工作详情
     */
    @Override
    public WorkDetail selectWorkDetailById(Long id) {
        return workDetailMapper.selectWorkDetailById(id);
    }

    /**
     * 查询工作详情列表
     * 
     * @param workDetail 工作详情
     * @return 工作详情
     */
    @Override
    public List<WorkDetail> selectWorkDetailList(WorkDetail workDetail) {
        return workDetailMapper.selectWorkDetailList(workDetail);
    }

    /**
     * 新增工作详情
     * 
     * @param workDetail 工作详情
     * @return 结果
     */
    @Override
    public WorkDetail insertWorkDetail(WorkDetail workDetail) {

      //  workDetailMapper.insertWorkDetail(workDetail);
    save(workDetail);
    return workDetail;
    }

    /**
     * 修改工作详情
     * 
     * @param workDetail 工作详情
     * @return 结果
     */
    @Override
    public WorkDetail updateWorkDetail(WorkDetail workDetail) {

      //  workDetailMapper.updateWorkDetail(workDetail);
        updateById(workDetail);
        return workDetail;
    }

    /**
     * 批量删除工作详情
     * 
     * @param ids 需要删除的工作详情主键
     * @return 结果
     */
    @Override
    public int deleteWorkDetailByIds(Long[] ids) {
        return workDetailMapper.deleteWorkDetailByIds(ids);
    }

    /**
    * 条件删除
    * @param workDetail 工作详情
    * @return
    */
    @Override
    public int delete(WorkDetail workDetail) {
        QueryWrapper<WorkDetail> qw = new QueryWrapper<>();
        QueryTool.condition(qw, workDetail);
        return baseMapper.delete(qw);
    }

    /**
     * mp分页
     * @param workDetail 工作详情
     * @return
     */
    @Override
    public Pages<WorkDetail> queryPage(WorkDetail workDetail) {
        QueryWrapper<WorkDetail> qw = new QueryWrapper<>();
        QueryTool.condition(qw, workDetail);
        IPage<WorkDetail> ipage = new Query<WorkDetail>().getPage(workDetail);

        IPage<WorkDetail> page = this.page(
                ipage,
                qw
        );
        return new Pages<>(page);
    }

    @Override
    public List<WorkDetail> selectWorkDetailListByWorkId(Long workId) {
        return list("work_id", workId);
    }

    @Override
    public boolean deleteWorkDetailByWorkId(Long workId) {
        return deleteBy("work_id", workId);
    }

    @Override
    public List<Map> countNum(WorkDetail workDetail) {
        return baseMapper.countNum(workDetail);
    }


    /**
     * 删除工作详情信息
     * 
     * @param id 工作详情主键
     * @return 结果
     */
    @Override
    public int deleteWorkDetailById(Long id) {
        return workDetailMapper.deleteWorkDetailById(id);
    }
}
